var t = require;
var e = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0});
var a = t("GuildCom"),
    i = (function () {
        function t() {
            this.canDo = !1;
            this.data = null;
            this.callNode = {};
            this.isDoOver = !1;
            this.mask = null;
            this.checkKey = "";
            this.addSize = cc.v2(0, 0);
            this.addSizeSpeeds = cc.v2(0, 0);
            this.isPlayAnimal = !1;
            this.parent = null;
        }
        t.prototype.reset = function (t, e, o, a, i) {
            this.checkKey = t;
            this.mask = o;
            this.canDo = !1;
            this.data = e;
            this.isDoOver = !1;
            this.callNode = {};
            this.addSizeSpeeds = cc.Vec2.ZERO;
            this.addSize = cc.Vec2.ZERO;
            this.isPlayAnimal = !1;
            this.parent = a;
            this.callClick = i;
        };
        t.prototype.canDoTask = function () {
            var t = this;
            this.isPlayAnimal && this.updatePlay();
            if (!this.canDo) {
                var e = !1;
                if (this.data && this.data.call)
                    for (
                        var o = this.data.call,
                            a = function (a) {
                                var n = a;
                                i.callNode[n]
                                    ? (e = !0)
                                    : GuildEv.emit(o[a].callKey, o[a].checkId, function (e) {
                                          t.callNode[n] = e;
                                          t.callClick && t.callClick(e);
                                      });
                            },
                            i = this,
                            n = 0;
                        n < o.length;
                        n++
                    )
                        a(n);
                else e = !0;
                e && (this.canDo = !0);
            }
            return this.canDo;
        };
        t.prototype.doTask = function () {
            if (!this.isDoOver) {
                this.isDoOver = !0;
                this.doKeyData();
            }
        };
        t.prototype.doKeyData = function () {
            switch (this.checkKey) {
                case "-1":
                    break;
                default:
                    this.playNode();
            }
        };
        t.prototype.getNodeToRectObj = function (t, e) {
            void 0 === e && (e = cc.v2(0, 0));
            var o = this.parent.convertToNodeSpaceAR(t.convertToWorldSpaceAR(cc.Vec2.ZERO));
            return {
                x: o.x - (t.width + e.x) * t.anchorX,
                y: o.y - (t.height + e.y) * t.anchorY,
                w: t.width + e.x,
                h: t.height + e.y
            };
        };
        t.prototype.getPlayNode = function (t) {
            var e = [];
            for (var o in this.callNode)
                if (this.callNode[o]) {
                    var a = this.getNodeToRectObj(this.callNode[o], t),
                        i = this.data.call[o].offDis || cc.Vec2.ZERO;
                    a.x += i.x;
                    a.y += i.y;
                    e.push(a);
                }
            return e;
        };
        t.prototype.clickAllAren = function () {
            this.data.clickBtn || this.checkClose();
        };
        t.prototype.touchStart = function () {
            this.sendHander("touchNodeStart");
        };
        t.prototype.sendHander = function (t) {
            for (var e in this.callNode)
                if (this.callNode[e]) {
                    var o = this.callNode[e].getComponent(a.default);
                    o && o[t] && "" != o[t].handler && o[t].emit([]);
                }
        };
        t.prototype.checkClose = function () {
            GuildCache.closeGuildView();
        };
        t.prototype.touchEnd = function () {
            this.sendHander("touchNodeEnd");
        };
        t.prototype.playNode = function () {
            this.addSize.x = 1334;
            this.addSize.y = 1334;
            this.addSizeSpeeds.x = this.addSize.x / 20;
            this.addSizeSpeeds.y = this.addSize.y / 20;
            this.isPlayAnimal = !0;
        };
        t.prototype.updatePlay = function () {
            if (this.addSize.x > 0 || this.addSize.y > 0) {
                this.addSize.x = Math.max(0, this.addSize.x - this.addSizeSpeeds.x);
                this.addSize.y = Math.max(0, this.addSize.y - this.addSizeSpeeds.y);
                this.mask.roundRect(this.getPlayNode(this.addSize), 10);
            } else {
                console.log("GuildDo ----------------- 播放解锁");
                this.isPlayAnimal = !1;
            }
        };
        return t;
    })();
o.default = i;
